<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/easyui/bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/easyui/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/easyui/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/easyui/css/common/box.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/easyui/css/common/checkbox.css">
    <script src="//unpkg.com/wangeditor/release/wangEditor.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/easyui/js/usershow.js"></script>
    <style type="text/css">
        a {
            color: black;
        }

        a:hover {
            text-decoration: none;
        }

        .bgc-w {
            background-color: #fff;
        }

        .paixu:HOVER {
            cursor: pointer;
            color: #337ab7;
        }
        /*下面是主题回复*/
        .chat-box .chat-title {
            padding: 10px;
            border-bottom: 1px solid #ddd;
        }

        .chat-box .big-img {
            border-radius: 50%;
            border: 2px solid #ddd;
            float: left;
            width: 40px;
            height: 40px;
        }

        .chat-box .small-img {
            border-radius: 50%;
            border: 2px solid #ddd;
            width: 30px;
            height: 30px;
        }

        .chat-box .username {
            display: block;
            margin-left: 50px;
        }

        .chat-box .right-time {
            margin-left: 50px;
            display: block;
        }

        .chat-box .comment-td {
            padding: 0;
            width: 40px;
        }

        .chat-box .raply-name {
            color: #54a0ea;
        }

        .addmore:HOVER {
            cursor: pointer;
        }

        .progress {
            margin: 4px auto;
        }

        .likethisnum a {
            color: #5f5f5f;
        }

        .likethisnum a:HOVER {
            color: #347ab7;
            text-decoration: underline;
        }
    </style>

</head>
<body>
<div class="row" style="padding-top: 10px;">
    <div class="col-md-2">
        <h1 style="font-size: 24px; margin: 0;" class="">我的管理</h1>
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true" data-backdrop="static" style="display: none;">
        <div class="modal-dialog" style="margin-top: 10%" ;="">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                            <span class="glyphicon glyphicon-remove-circle"
                                                  style="font-size: 26px;"></span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        评论
                    </h4>
                </div>
                <div class="modal-body">
                    <textarea rows="8" cols="78" id="comment"></textarea>
                </div>
                <input type="hidden" id="commentid">
                <input type="hidden" id="replytype">
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="commentsave"
                            data-dismiss="modal">提交
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <!--盒子头-->
    <div class="box-header">
        <h3 class="box-title">
            <a href="javascript:void(0)" class="label label-success add_discuss" style="padding: 5px;position:relative;left:720px;">
                <span class="glyphicon glyphicon-plus"></span> 新增
            </a>
        </h3>
        <div class="box-tools">
            <div class="input-group" style="width: 150px;">
                <input type="text" class="form-control input-sm baseKey" placeholder="按标题查找">
                <div class="input-group-btn">
                    <a class="btn btn-sm btn-default baseKetsubmit chazhao"><span
                            class="glyphicon glyphicon-search"></span></a>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row" style="padding-top: 15px;">
    <div class="col-md-12 thistable">
        <!--id="container"-->
        <div class="bgc-w box box-primary">
            <!--盒子身体-->
            <div class="box-body no-padding">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <tbody>
                        <tr>
                            <th scope="col"><span class="paixu thistype">类型
						</span></th>
                            <th scope="col">标题</th>
                            <th scope="col"><span class="paixu thistime">发布时间
						</span></th>
                            <th scope="col">发布人</th>
                            <th scope="col"><span class="paixu thisvisit">访问量
						</span></th>
                            <th scope="col">点赞数</th>
                            <th scope="col">评论数</th>
                            <th scope="col">附件</th>
                            <th scope="col">操作</th>
                        </tr>
                        <tr>
                            <td><span class="label label-danger">公告</span></td>
                            <td style="max-width:200px;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;">
                                <span>测试帖子</span></td>
                            <td><span>2017-10-01 14:37:39</span></td>
                            <td><span>猿来入此</span></td>
                            <td><span>35</span></td>
                            <td><span>0</span></td>
                            <td><span>8</span></td>
                            <td><span>附件</span></td>
                            <td>
                                <a href="/writechat?id=14" class="label xiugai"><span
                                        class="glyphicon glyphicon-edit"></span> 修改</a>
                                <a href="/seediscuss?id=14&amp;pageNumber=0" class="label xiugai"> <span
                                        class="glyphicon glyphicon-search"></span>查看</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!--盒子尾-->
            <div class="box-footer no-padding" style="margin-top: -20px;">
                <div style="padding: 5px;">
                    <div id="page" style="background: #fff; border: 0px; margin-top: 0px; padding: 2px; height: 25px;">
                        <div style="width: 40%; float: left;">
                            <div class="pageInfo" style="margin-left: 5px;">
                                共<span>4</span>条 | 每页<span>10</span>条
                                | 共<span>1</span>页
                            </div>
                        </div>
                        <div style="width: 60%; float: left;">
                            <div class="pageOperation">
                                <!--判断是否是第一页  -->
                                <a class="btn btn-sm btn-default no-padding tablefirst" disabled="disabled"
                                   style="width: 30px; height: 20px;"> <span
                                        class="glyphicon glyphicon-backward"></span></a>
                                <a class="btn btn-sm btn-default no-padding tableup" disabled="disabled"
                                   style="width: 30px; height: 20px;"> <span
                                        class="glyphicon glyphicon-triangle-left"></span></a>
                                <a disabled="disabled" class="btn btn-default no-padding"
                                   style="width: 30px; height: 20px;">
                                    1
                                </a>
                                <!--判断是否是最后一页  -->
                                <a class="btn btn-sm btn-default no-padding tabledown" disabled="disabled"
                                   style="width: 30px; height: 20px;"> <span
                                        class="glyphicon glyphicon-triangle-right"></span></a>
                                <a class="btn btn-sm btn-default no-padding tablelast" disabled="disabled"
                                   style="width: 30px; height: 20px;"> <span class="glyphicon glyphicon-forward"></span></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 模态框（Modal） -->
<!--class nothing 完毕-->
<script>
    /* 点击加载更多 */
    $('.addmore').on('click', function () {
        var selecttype = $("#selecttype option:selected").val();	//获得查看类型select中的值
        var selectsort = $("#selectsort option:selected").val();	//获得时间排序select中的值
        var num = 14;
        var page = 0;
        var size = 10;
        if (5 <= 3) {
            $('.repay').load('/replypaging', {
                num: num,
                size: size,
                selecttype: selecttype,
                selectsort: selectsort
            });
        }
    });

</script>
<!-- 存在 -->
<script type="text/javascript">
    /*  */
    $('.repay').on('click', '.thisreply', function () {
        $("#hiddenreplyId").val($(this).attr('replyId'));
        $("#hiddenreplyModule").val($(this).attr('replyModule'));
        var name = $(this).attr('replyName');
        $('.replyName').val(name);
        console.log(typeof (name));
        if (typeof (name) != 'undefined') {
            $("#comment").val("@" + name);
        }
        $("#myModal").modal("toggle");
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        var pageNum = 1;
        var pageSize = 6;
        var userId = "${sessionScope.accountMap.accountId}";
        //一进来就进行数据请求
        getAjax(pageNum,pageSize,userId);
        //页面渲染
        function getAjax(pageNum,pageSize,userId) {
            $.ajax({
                async:true,
                url:"${pageContext.request.contextPath}/getDiscuss",
                type:"get",
                dataType:"json",
                data:{
                    pageNum:pageNum,
                    pageSize:pageSize,
                    condition:$(".baseKey").val(),
                    userId:userId
                },
                success:function (result) {
                    var table_body_content = "<div class=\"bgc-w box box-primary\">\n" +
                        "            <!--盒子身体-->\n" +
                        "            <div class=\"box-body no-padding\">\n" +
                        "                <div class=\"table-responsive\">\n" +
                        "                    <table class=\"table table-hover\">\n" +
                        "                        <tbody>\n" +
                        "                        <tr>\n" +
                        "                            <th scope=\"col\"><span class=\"paixu thistype\">类型\n" +
                        "\t\t\t\t\t\t</span></th>\n" +
                        "                            <th scope=\"col\">标题</th>\n" +
                        "                            <th scope=\"col\"><span class=\"paixu thistime\">发布时间\n" +
                        "\t\t\t\t\t\t</span></th>\n" +
                        "                            <th scope=\"col\">发布人</th>\n" +
                        "                            <th scope=\"col\"><span class=\"paixu thisvisit\">访问量\n" +
                        "\t\t\t\t\t\t</span></th>\n" +
                        "                            <th scope=\"col\">操作</th>\n" +
                        "                        </tr>";
                    $.each(result.list,function (index,discuss) {
                        table_body_content += " <tr>\n" ;
                        if (discuss.typeId == 19){
                            table_body_content +=  "<td><span class=\"label label-danger\">公告</span></td>\n";
                        }else if (discuss.typeId == 20){
                            table_body_content +=  "<td><span class=\"label label-success\">讨论</span></td>\n";
                        }else{
                            table_body_content +=  "<td><span class=\"label label-warning\">投票</span></td>\n";
                        }

                        table_body_content +=   "        <td style=\"max-width:200px;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;\">\n" +
                            "                                <span>"+discuss.title+"</span></td>\n" +
                            "                            <td><span>"+discuss.createTime+"</span></td>\n" +
                            "                            <td><span>"+discuss.discussUserName+"</span></td>\n" +
                            "                            <td><span>"+discuss.visitNum+"</span></td>\n" +
                            "                            <td>\n" +
                            "                                <a href=\"javascript:void(0)\" class=\"label xiugai update\" data-discussid=\""+discuss.discussId+"\"><span\n" +
                            "                                        class=\"glyphicon glyphicon-edit\"></span> 修改</a>"+
                            "                                <a href=\"javascript:void(0)\" class=\"label xiugai view\" data-discussid=\""+discuss.discussId+"\" data-visitnum=\""+discuss.visitNum+"\"> <span\n" +
                            "                                        class=\"glyphicon glyphicon-search\"></span>查看</a>\n" +
                            "                            </td>\n" +
                            "                        </tr>";
                    });
                    table_body_content += "</tbody>\n" +
                        "                    </table>\n" +
                        "                </div>\n" +
                        "            </div>";
                    //分页渲染内容
                    var pageContent = " <div class=\"box-footer no-padding\" style=\"margin-top: -20px;\">\n" +
                        "                <div style=\"padding: 5px;\">\n" +
                        "                    <div id=\"page\" style=\"background: #fff; border: 0px; margin-top: 0px; padding: 2px; height: 25px;\">\n" +
                        "                        <div style=\"width: 40%; float: left;\">\n" +
                        "                            <div class=\"pageInfo\" style=\"margin-left: 5px;\">\n" +
                        "                                共<span>"+result.total+"</span>条 | 每页<span>"+result.pageSize+"</span>条\n" +
                        "                                | 共<span>"+result.pages+"</span>页\n" +
                        "                            </div>\n" +
                        "                        </div>\n" +
                        "                        <div style=\"width: 60%; float: left;\">\n" +
                        "                            <div class=\"pageOperation\">";
                    //首页+上一页
                    if (result.pageNum == 1){
                        pageContent += "<a class=\"btn btn-sm btn-default no-padding tablefirst\" disabled=\"disabled\" title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                            "                                    <span class=\"glyphicon glyphicon-backward\"></span>\n" +
                            "                                </a>\n" +
                            "                                <a class=\"btn btn-sm btn-default no-padding tableup\" disabled=\"disabled\" title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                            "                                    <span class=\"glyphicon glyphicon-triangle-left\"></span>\n" +
                            "                                </a>";
                    }else{
                        pageContent += "<a class=\"btn btn-sm btn-default no-padding tablefirst\"  title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                            "                                    <span class=\"glyphicon glyphicon-backward\"></span>\n" +
                            "                                </a>\n" +
                            "                                <a class=\"btn btn-sm btn-default no-padding tableup\"title=\""+result.prePage+"\" style=\"width: 30px; height: 20px;\">\n" +
                            "                                    <span class=\"glyphicon glyphicon-triangle-left\"></span>\n" +
                            "                                </a>";
                    }
                    // 页码
                    for (let i = 1;i<=result.pages;i++){
                        if (result.pageNum == i){
                            pageContent += " <a disabled=\"disabled\" class=\"btn btn-default no-padding num\" title=\""+i+"\" style=\"width: 30px; height: 20px;\">\n" +
                                ""+i+"\n" +
                                "</a>";
                        }else{
                            pageContent += " <a class=\"btn btn-default no-padding num\" title=\""+i+"\" style=\"width: 30px; height: 20px;\">\n" +
                                ""+i+"\n" +
                                "</a>";
                        }
                    }
                    //下一页和尾页
                    if (result.pageNum == result.pages){
                        pageContent += " <a class=\"btn btn-sm btn-default no-padding tabledown\" disabled=\"disabled\" title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                            "                                    <span class=\"glyphicon glyphicon-triangle-right\"></span>\n" +
                            "                                </a>\n" +
                            "                                <a class=\"btn btn-sm btn-default no-padding tablelast\" disabled=\"disabled\" title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                            "                                    <span class=\"glyphicon glyphicon-forward\"></span>\n" +
                            "                                </a>";
                    } else{
                        pageContent += " <a class=\"btn btn-sm btn-default no-padding tabledown\"  title=\""+result.nextPage+"\" style=\"width: 30px; height: 20px;\">\n" +
                            "                                    <span class=\"glyphicon glyphicon-triangle-right\"></span>\n" +
                            "                                </a>\n" +
                            "                                <a class=\"btn btn-sm btn-default no-padding tablelast\"  title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                            "                                    <span class=\"glyphicon glyphicon-forward\"></span>\n" +
                            "                                </a>";

                    }
                    table_body_content += pageContent;
                    table_body_content += "</div>\n" +
                        "                        </div>\n" +
                        "                    </div>\n" +
                        "                </div>\n" +
                        "            </div>\n" +
                        "        </div>";
                    $(".thistable").html(table_body_content);
                },
                error:function () {
                    alert("ajax请求失败！")
                }
            })
        };
        /*返回事件*/
        $(document).on("click","#goback",function () {
            getAjax(pageNum,pageSize,userId);
        });
        /*取消事件*/
        $(document).on("click","#cancel",function () {
            getAjax(pageNum,pageSize,userId);
        });
        /*分页数据渲染*/
        $(document).on("click",".pageOperation a",function () {
            getAjax($(this).prop("title"),pageSize,userId);
        });
        /*搜索按钮点击事件*/
        $(".chazhao").click(function () {
            getAjax(pageNum,pageSize,userId);
        })
        /*修改事件*/
        $(document).on("click",".update",function () {
            $.ajax({
                async:true,
                url:"${pageContext.request.contextPath}/getDiscussById",
                type:"get",
                dataType:"json",
                data:{
                    discussId:$(this).data("discussid")
                },
                success:function (result) {
                    var content = "     <div class=\"bgc-w box box-primary\" style=\"min-height: 613px;margin-top:20px;\">\n" +
                        "                <!--盒子头-->\n" +
                        "                <div class=\"box-header\">\n" +
                        "                <h3 class=\"box-title\">\n" +
                        "                <a href=\"javascript:void(0);\" class=\"label label-default\" style=\"padding: 5px;\" id=\"goback\"> <i class=\"glyphicon glyphicon-chevron-left\"></i> <span>返回</span>\n" +
                        "            </a>\n" +
                        "            </h3>\n" +
                        "            </div>\n" +
                        "            <div class=\"alert alert-danger alert-dismissable\" style=\"display: none;\" role=\"alert\">\n" +
                        "                错误信息:\n" +
                        "        <button class=\"thisclose close\" type=\"button\">×</button>\n" +
                        "            <span class=\"error-mess\"></span>\n" +
                        "                </div>\n" +
                        "                <!--盒子身体-->\n" +
                        "                <form method=\"get\" enctype=\"application/x-www-form-urlencoded\" id=\"updateform\">\n" +
                        "                <div class=\"box-body\">\n" +
                        "                <!--错误信息提示  -->\n" +
                        "                <div class=\"form-group\">\n" +
                        "                <select name=\"typeId\" id=\"selecttype\" class=\"select2 form-control\" disabled=\"disabled\">\n";
                    if(parseInt(result.typeId) == 19){
                        content +=  "     <option value=\"19\" selected>公告</option>\n" +
                            "                <option value=\"20\">讨论</option>\n" +
                            "                <option value=\"21\">投票</option>\n";
                    }else if (parseInt(result.typeId) == 20){
                        content +=  "     <option value=\"19\">公告</option>\n" +
                            "                <option value=\"20\" selected>讨论</option>\n" +
                            "                <option value=\"21\">投票</option>\n";
                    } else{
                        content +=  "     <option value=\"19\">公告</option>\n" +
                            "                <option value=\"20\">讨论</option>\n" +
                            "                <option value=\"21\" selected>投票</option>\n";
                    }
                    content += "    </select>\n" +
                        "                </div>\n" +
                        "                <div class=\"form-group\" style=\"margin-top:10px;\">\n" +
                        "                <input name=\"title\" type=\"text\" class=\"form-control title\" placeholder=\"标题：\" value=\""+result.title+"\">\n" +
                        "                </div>\n" +
                        "                <input type=\"hidden\" value=\""+result.discussId+"\" name=\"discussId\"/> "+
                        "                <textarea style=\"display:none;\" name=\"discussContent\" value=\"gdf\" id=\"discussContent\"></textarea>"+
                        "                <div class=\"form-group\" id=\"editor\">\n" +
                        "                </div>\n" +
                        "                \n" +
                        "            </div>\n" +
                        "            <div class=\"box-footer foots\">\n" +
                        "                <div class=\"left1\">\n" +
                        "                <input type=\"button\" class=\"btn btn-primary \" value=\"发送\" id=\"send\">\n" +
                        "                <a class=\"btn btn-default\" id=\"cancel\"><span>取消</span></a>\n" +
                        "            </div>\n" +
                        "            </div>\n" +
                        "            </form>\n" +
                        "            </div>";
                    $(".thistable").html(content);
                    var E = window.wangEditor;
                    var editor = new E('#editor');
                    editor.create();
                    editor.txt.html(result.content);
                },
                error:function () {
                    alert("ajax请求失败！")
                }
            })

        });
      //修改事件
      $(document).on("click","#send",function () {
          //表单数据
          $("#discussContent").html($(".w-e-text").html());
          var formdata = $("#updateform").serialize();
          //发送ajax请求
          $.ajax({
              async: true,
              url:"${pageContext.request.contextPath}/updateDiscuss",
              type:"get",
              dataType:"json",
              data:formdata,
              success:function (result) {
                if (parseInt(result) == 1){
                    alert("修改成功！")
                    getAjax(pageNum,pageSize,userId);
                }else{
                    alert("修改失败！")
                }
              },
              error:function () {
                  alert("Ajax请求失败！");
              }

          })
      });
        /*新增事件*/
        $(".add_discuss").click(function () {
            var content = "<div class=\"bgc-w box box-primary\" style=\"min-height: 613px;margin-top:20px;\">\n" +
                "                <!--盒子头-->\n" +
                "                <div class=\"box-header\">\n" +
                "                <h3 class=\"box-title\">\n" +
                "                <a href=\"javascript:void(0);\" class=\"label label-default\" style=\"padding: 5px;\" id=\"goback\"> <i class=\"glyphicon glyphicon-chevron-left\"></i> <span>返回</span>\n" +
                "            </a>\n" +
                "            </h3>\n" +
                "            </div>\n" +
                "            <div class=\"alert alert-danger alert-dismissable\" style=\"display: none;\" role=\"alert\">\n" +
                "                错误信息:\n" +
                "        <button class=\"thisclose close\" type=\"button\">×</button>\n" +
                "            <span class=\"error-mess\"></span>\n" +
                "                </div>\n" +
                "                <!--盒子身体-->\n" +
                "                <form enctype=\"application/x-www-form-urlencoded\" id=\"addform\">\n" +
                "                <div class=\"box-body\">\n" +
                "                <!--错误信息提示  -->\n" +
                "                <div class=\"form-group\">\n" +
                "                <select name=\"typeId\" id=\"selecttype\" class=\"select2 form-control\">\n" +
                "                <option value=\"19\">公告</option>\n" +
                "                <option value=\"20\">讨论</option>\n" +
                "                <option value=\"21\">投票</option>\n" +
                "                </select>\n" +
                "                </div>\n" +
                "                <div class=\"form-group\" style=\"margin-top:10px;\">\n" +
                "                <input name=\"title\" type=\"text\" class=\"form-control title\" placeholder=\"标题：\" value=\"\">\n" +
                "                </div>\n" +
                "                <input type=\"hidden\" value=\""+userId+"\" name=\"userId\"/> "+
                "                <textarea style=\"display:none;\" name=\"discussContent\" value=\"gdf\" id=\"discussContent\"></textarea>"+
                "                <div class=\"form-group\" id=\"editor\">\n" +
                "                </div>\n" +
                "                \n" +
                "            </div>\n" +
                "            <!--盒子尾-->\n" +
                "            <div class=\"box-footer foots\">\n" +
                "                <div class=\"left1\">\n" +
                "                <input type=\"button\" class=\"btn btn-primary \" id=\"add_send\" value=\"发送\">\n" +
                "                <a class=\"btn btn-default\" id=\"cancel\"><span>取消</span></a>\n" +
                "            </div>\n" +
                "            </div>\n" +
                "            </form>\n" +
                "            </div>";
            $(".thistable").html(content);
            var E = window.wangEditor;
            var editor = new E('#editor');
            editor.create();
        });
        $(document).on("click","#add_send",function () {
            //表单数据
            $("#discussContent").html($(".w-e-text").html());
            var formdata = $("#addform").serialize();
            //发送ajax请求
            $.ajax({
                async: true,
                url:"${pageContext.request.contextPath}/addDiscuss",
                type:"get",
                dataType:"json",
                data:formdata,
                success:function (result) {
                    if (parseInt(result) == 1){
                        alert("添加成功！")
                        getAjax(pageNum,pageSize,userId);
                    }else{
                        alert("添加失败！")
                    }
                },
                error:function () {
                    alert("Ajax请求失败！");
                }

            })
        });
        /*查看按钮事件*/
        $(document).on("click",".view",function () {
            /*当点击查看的时候，去请求数据库，将访问数加1，并且返回所有的回复以及评论*/
            var discuss_Id = $(this).data("discussid");
            var visit_num = $(this).data("visitnum");
            getDiscussAjax(discuss_Id,visit_num);
        });
        //查看结果页面渲染
        function getDiscussAjax(discuss_Id,visit_num){
            $.ajax({
                async:true,
                url:"${pageContext.request.contextPath}/getDiscussDetails",
                type:"get",
                dataType:"json",
                data:{
                    discussId:discuss_Id,
                    visitNum:visit_num
                },
                success:function (result) {
                    var content = "<div class=\"bgc-w box box-primary\" style=\"border-top: 3px solid #d2d6de; color: #5f5f5f;\">\n" +
                        "            <!--盒子头-->\n" +
                        "            <div class=\"box-header\">\n" +
                        "                <h3 class=\"box-title\">\n" +
                        "                    <a href=\"javascript:void(0);\" class=\"label label-default\" style=\"padding: 6px;\" id=\"goback\"> <span\n" +
                        "                            class=\"glyphicon glyphicon-chevron-left\">返回</span>\n" +
                        "                    </a>\n" +
                        "                </h3>\n" +
                        "\n" +
                        "            </div>\n" +
                        "            <!--盒子身体-->\n" +
                        "            <div class=\"box-body no-padding chat-box\">\n" +
                        "                <div class=\"chat-title\">\n" +
                        "                    <h4>\n" +
                        "                        <span>"+result.title+"</span>\n" +
                        "                    </h4>\n" +
                        "                    <h5>\n" +
                        "                        <small><span>发布:"+result.discussUserName+"</span> <span class=\"pull-right\">"+result.createTime+"</span>\n" +
                        "                        </small>\n" +
                        "                    </h5>\n" +
                        "                </div>\n" +
                        "                <div style=\"padding: 10px;\">\n" +
                        "                    <div class=\"chat-content\" style=\"padding: 10px;\">"+result.content+"</div>\n" +
                        "                    <div>\n" +
                        "                        <div class=\"discusschange\">\n" +
                        "                            <ul class=\"list-inline\" style=\"margin-left: 6px;\">\n" +
                        "                                <li><a href=\"javascript:void(0);\" class=\"label xinzeng thisreply\" id=\"thisreply\" data-discussid=\""+result.discussId+"\" replyid=\"14\" replymodule=\"discuss\" data-toggle=\"modal\" data-target=\"#myModal\">\n" +
                        "                                       <span class=\"glyphicon glyphicon-share-alt\"></span>回复\n" +
                        "                                    </a>\n" +
                        "                                </li>\n" +
                        "                                <li>\n" +
                        "                                    <a href=\"javascript:void(0);\"> <span class=\"glyphicon glyphicon-fire\" style=\"color: red;\"></span>\n" +
                        "                                        访问数<span>("+result.visitNum+")</span>\n" +
                        "                                    </a>\n" +
                        "                                </li>\n" +
                        "                            </ul>\n" +
                        "                            <ul class=\"list-inline\" style=\"margin-left: 10px;\">\n" +
                        "                            </ul>\n" +
                        "                        </div>\n" +
                        "                        <input type=\"hidden\" class=\"replyId\"><input type=\"hidden\" class=\"replyModule\"><input\n" +
                        "                            type=\"hidden\" class=\"replyName\" value=\"猿来入此\">\n" +
                        "                    </div>\n" +
                        "                    <div>\n" +
                        "                        <table class=\"table\" style=\"margin-bottm: 0px;\">\n" +
                        "                            <tbody>\n" +
                        "                            <tr>\n" +
                        "                                <th scope=\"col\" style=\"background-color: #EEEEEE;\">\n" +
                        "                                    <span style=\"line-height: 35px;\">回复</span>\n" +
                        "                                </th>\n" +
                        "                            </tr>\n" +
                        "                            </tbody>\n" +
                        "                            <tbody class=\"repay\">\n";
                    $.each(result.replies,function (index,reply) {
                        content += "                   <tr>\n" +
                            "                                <td>\n" +
                            "                                    <div class=\"post\">\n" +
                            "                                        <div class=\"user-block\">\n" +
                            "\t\t\t\t                            <span> <a href=\"javascript:void(0);\"> <img src=\"${pageContext.request.contextPath}/static/easyui/images/1.jpg\" class=\"big-img\"></a></span>\n" +
                            "                                            <span class=\"username\">\n" +
                            "                                                <a href=\"javascript:void(0);\" class=\"raply-name\">"+reply.replyUserName+"</a>\n" ;
                        if (parseInt(reply.replyUserId) == userId){
                            content += "\t\t\t\t\t                     <a replyid=\"17\" replymodule=\"reply\" href=\"javascript:void(0);\" class=\"deletethis pull-right\" style=\"font-size: 12px;\" data-type=\"回复\" data-id=\""+reply.replyId+"\">\n" +
                                "\t\t\t\t\t                                <span style=\"font-size: 16px;\">×</span>\n" +
                                "\t\t\t\t\t                            </a>\n" ;
                        }else{
                            content += "\t\t\t\t\t                     <a replyid=\"17\" replymodule=\"reply\" href =\"javascript:return false;\" onclick=\"return false;\" style=\"cursor: default;pointer-events: none;\" class=\"deletethis pull-right\" style=\"font-size: 12px;\" data-type=\"回复\" data-id=\""+reply.replyId+"\">\n" +
                                "\t\t\t\t\t                                <span style=\"font-size: 16px;opacity: 0.2;\">×</span>\n" +
                                "\t\t\t\t\t                            </a>\n" ;
                        }

                            content += "\t\t\t\t                    </span>\n" +
                            "                                            <span class=\"right-time\">"+reply.replyTime+"</span>\n" +
                            "                                                <p style=\"padding-top: 10px;\">"+reply.content+"</p>\n" +
                            "                                            <div class=\"replyrefresh\">\n" +
                            "                                                <ul class=\"list-inline\">\n" +
                            "                                                    <li>\n" +
                            "                                                        <a href=\"javascript:void(0);\" class=\"thisreply\" id=\"subreply\" data-replyid=\""+reply.replyId+"\" replyid=\"17\" replymodule=\"reply\" data-toggle=\"modal\" data-target=\"#myModal\">\n" +
                            "                                                            <span class=\"glyphicon glyphicon-share-alt\"></span> 回复\n" +
                            "                                                         </a>\n" +
                            "                                                    </li>\n" +
                            "                                                    <li>\n" +
                            "                                                        <a href=\"#comment"+(index+1)+"\" class=\"label xiugai toggle collapsed\"\n" +
                            "                                                           data-toggle=\"collapse\" aria-expanded=\"false\"><span\n" +
                            "                                                            class=\"glyphicon glyphicon-triangle-bottom\"></span>评论次数("+reply.comments.length+")</a>\n" +
                            "                                                    </li>\n" +
                            "                                                    <li class=\"pull-right\">\n" +
                            "\t\t                                                <span class=\"rightNum\">"+(index+1)+"</span>楼\n" +
                            "                                                    </li>\n" +
                            "                                                </ul>\n" +
                            "                                            </div>\n" +
                            "                                            <div id=\"comment"+(index+1)+"\" class=\"comment collapse\"\n" +
                            "                                                 style=\"margin-left: 80px; height: 0px;\" aria-expanded=\"false\">\n" +
                            "                                                <table class=\"table table-hover\" style=\"margin-bottom: 0;\">\n" +
                            "                                                    <tbody>\n";
                        $.each(reply.comments,function (index,comment) {
                            content+= "                                          <tr>\n" +
                                "                                                        <td class=\"comment-td\"><a href=\"javascript:void(0);\"> <img\n" +
                                "                                                                src=\"${pageContext.request.contextPath}/static/easyui/images/1.jpg\"\n" +
                                "                                                                class=\"big-img\">\n" +
                                "                                                        </a></td>\n" +
                                "                                                        <td>\n" +
                                "                                                            <div class=\"user-block\">\n" +
                                "                                                                <a href=\"\" class=\"raply-name\">"+comment.userName+": </a>"+comment.content+"\n" +
                                "                                                                <ul class=\"list-inline pull-right\"\n" +
                                "                                                                    style=\"display: block;\">\n";
                            if (parseInt(comment.commentUserId) == userId){
                                content += "<li style=\"position:relative;left:13px;\">"+comment.time+"</li>\n";
                                content += "                                                      <li><a href=\"javascript:void(0);\" class=\"label shanchu deletethis\" data-type=\"评论\" data-id=\""+comment.commentId+"\" replyid=\"26\" replymodule=\"comment\">\n" +
                                    "                                                                      <span class=\"glyphicon glyphicon-remove\"></span>删除</a>\n" +
                                    "                                                                  </li>\n";
                            }else{
                                content += "<li style=\"position:relative;left:-53px;\">"+comment.time+"</li>\n";
                            }
                            content += "                                                     </ul>\n" +
                                "                                                            </div>\n" +
                                "                                                        </td>\n" +
                                "                                                    </tr>\n" ;
                        });

                        content += "                                          </tbody>\n" +
                            "                                                </table>\n" +
                            "                                            </div>\n" +
                            "                                        </div>\n" +
                            "                                    </div>\n" +
                            "                                </td>\n" +
                            "                            </tr>\n" ;
                    });
                    content += "                 <tr>\n" +
                        "                                <th scope=\"col\" style=\"background-color: #EEEEEE;text-align: center;padding:16px;\"\n" +
                        "                                    class=\"addmore\">\n" +
                        "                                    <span class=\"nomore\">已经没有更多了~~~</span>\n" +
                        "                                </th>\n" +
                        "                            </tr>\n" +
                        "                            </tbody>\n" +
                        "                        </table>\n" +
                        "                        <input type=\"hidden\" id=\"hiddenreplyId\" value=\"17\">\n" +
                        "                        <input type=\"hidden\" id=\"hiddenreplyModule\" value=\"reply\">\n" +
                        "                    </div>\n" +
                        "                </div>\n" +
                        "                <!--盒子尾-->\n" +
                        "            </div>\n" +
                        "        </div>";
                    $(".thistable").html(content);
                },
                error:function () {
                    alert("ajax请求失败！")
                }
            })
        }
        $(document).on("click","#subreply",function () {
            $("#commentid").val($(this).data("replyid"));
            $("#replytype").val("二级评论");
        });
        $(document).on("click","#thisreply",function () {
            $("#commentid").val($(this).data("discussid"));
            $("#replytype").val("一级评论");
        });
        /*回复发送事件*/
        $("#commentsave").click(function () {
            var comment_id = $("#commentid").val();
            var replytype = $("#replytype").val();
            var comment = $("#comment").val();
            var discuss_id = $("#thisreply").data("discussid");
            var visit_num = "";
            $.ajax({
                async:true,
                url:"${pageContext.request.contextPath}/sendComment",
                type:"get",
                dataType:"text",
                data:{
                    commentId:comment_id,
                    replytype:replytype,
                    comment:comment,
                    userId:userId
                },
                success:function (result) {
                    if(parseInt(result) == 1){
                        alert("评论成功！")
                        $("#comment").val("");
                        getDiscussAjax(discuss_id,visit_num)
                    }else{
                        alert("评论失败！")
                    }
                },
                error:function () {
                    alert("ajax请求失败！")
                }
            })
        });
        /*删除事件*/
        $(document).on("click",".deletethis",function () {
            var type = $(this).data("type");
            var id = $(this).data("id");
            var discuss_id = $("#thisreply").data("discussid");
            var visit_num = "";
            $.ajax({
                async:true,
                url:"${pageContext.request.contextPath}/removeComment",
                type:"get",
                dataType:"text",
                data:{
                    commentId:id,
                    replytype:type,
                },
                success:function (result) {
                    if(parseInt(result) == 1){
                        alert("删除成功！");
                        getDiscussAjax(discuss_id,visit_num)
                    }else{
                        alert("删除失败！")
                    }
                },
                error:function () {
                    alert("ajax请求失败！")
                }
            })
        })
    })
</script>
</html>